<?php Util::tsRegisterAssetJs('reportFrmHistorial.js'); ?>

<?php
/** @var LlamadaController $this */
/** @var Llamada $model */
$this->menu = array(
    array(
        'label' => 'Exportar', 'icon' => 'download-alt', 'url' => '#', 'items' => array(
            array('label' => 'Todos', 'url' => '#', 'linkOptions' => array(
                    'onclick' => 'ExporEncuestas(true, $("#search_value").val(),' . $model->nosey_form_id . ')',),),
            array('label' => 'Seleccionados', 'url' => '#', 'linkOptions' => array(
                    'onclick' => 'ExporEncuestas(false, "",' . $model->nosey_form_id . ')',),)
        ),
    ),
);
?>

<div class="widget blue">

    <div class="widget-title">
        <h4><i class="icon-phone"></i>  <?php echo Yii::t('AweCrud.app', 'Historial ') ?> <?php echo Form::label(2) ?>  </h4>
        <span class="tools">
            <a href="javascript:;" class="icon-chevron-down"></a>
        </span>
    </div>
    <div class="widget-body">

        <div class="row-fluid">

            <div class="control-label required span1">Filtro <span class="required">*</span></div>

            <div class="search-form">
                <?php
                $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
                    'action' => Yii::app()->createUrl("reportFrmHistoria"),
                    'method' => 'get',
                ));
                ?>
                <?php
                $this->widget('ext.bootstrap.widgets.TbDateRangePicker', array(
                    'name' => 'search[value]',
                    'options' => array(
                        'format' => 'dd/MM/yyyy',
                        'ranges' => array(
                            'Hoy' => array('today', 'today'),
                            'Ayer' => array('yesterday', 'yesterday'),
                            'Semana actual' => array('monday', 'today'),
                            'Semana Anterior' => array(Util::calcularSemanaAnterior(0), Util::calcularSemanaAnterior(1)),
                            'Mes Actual' => array(Util::obtenerPrimerDiaMes(), Util::obtenerUltimoDiaMes()),
                            'Mes Anterior' => array(Util::calcularMesAnterior(0), Util::calcularMesAnterior(1)),
                        )
                    ),
                    'callback' => 'js:function(){search()}',
                    'htmlOptions' => array(
                        'readonly' => true,
                        'class' => "search_value"
                    ),
                ));
                ?>
                <?php $this->endWidget(); ?>
            </div>


        </div>
        <div class='gridAdmin' style='overflow:auto;'>
            <?php
            $this->widget('ext.selgridview.BootSelGridView', array(
                'id' => 'reportFrmHist-grid',
                'type' => 'striped bordered hover advance',
                'selectableRows' => 2,
                'dataProvider' => $model->search(),
                'columns' =>
                array_merge(
                        array(
                    array(
                        'name' => 'id',
                        'id' => 'check',
                        'class' => 'CCheckBoxColumn',
                        'value' => '$data->id',
                    ),
                    array(
                        'header' => 'Cuenta',
                        'value' => '$data->contactorel->cuenta?$data->contactorel->cuenta->nombre:""',
                    ),
                    array(
                        'header' => 'Contacto',
                        'value' => '$data->contactorel->nombre_completo',
                    ),
                    array(
                        'header' => 'Identificación',
                        'value' => '$data->contactorel->documento',
                    ),
                    array(
                        'header' => 'Campaña',
                        'value' => '$data->entidad_id',
                    ),
                    array(
                        'header' => 'Formulario',
                        'value' => '$data->form->name',
                    ),
                    array(
                        'header' => 'Fecha',
                        'value' => 'Util::FormatDate($data->answers->creation_date, "d/m/Y H:m:s")',
                    ),
                        ), $model->createGrid($model->nosey_form_id))
            ));
            ?>
        </div>
    </div>
</div>
<form id="formId" method="post" target="blank">
    <input type="hidden" id="id_encuesta" name="Encuesta">
</form>